<script>
$(function() {
	$( ".datepick" ).datepicker({
								 minDate: new Date(),
								 changeMonth: true,
								changeYear: true,
								dateFormat: "yy-mm-dd",
								buttonImage:$('#root').val()+"img/calendar.jpg"
	 							});
});
function addrow()
{
	$(".tbchithi tr:last").clone(true).insertAfter(".tbchithi tr:last");
	}
$(document).ready(function () {          
    $(".btthem").click(function() {
        addrow();
        $(".tbchithi tr:last input").val("");
        $(".tbchithi tr:last input:first").focus();
           // $("table.tbchithi tr:last").after('<tr><td>Row 4</td></tr>');
            //return false;
    });
});
</script>
<div id="tabs">
	<ul>
        <li><?php echo $this->Html->link(__('Danh sách công việc', true), array('controller'=>'khtuans','action' => 'index',$kehoach));?></li>
	
        <li id="current"><?php echo $this->Html->link(__('Thêm', true), array('controller' => 'khtuans', 'action' => 'add',$kehoach)); ?></a> </li>
        </ul>
</div>
<div class="khtuans index">
<h2><?php __('Kế hoạch công tác tuần do '.$kh['Donvi']['tendv'].' lập');?></h2>
<h3><?php echo 'Từ ngày '.$kh['Kehoach']['ngaybd'].' đến ngày '.$kh['Kehoach']['ngaykt'];?>
</h3>

<p>
<?php
echo $form->input('root',array('id'=>'root','type'=>'hidden','value'=>$this->webroot));
echo $paginator->counter(array(
'format' => __('Trang %page%/%pages%, hiện có %count% công việc', true)
));
?></p>
<div style="width:1050px; overflow:auto">
<table cellpadding="0" cellspacing="0" id="tables">
<tr>
	<th rowspan="2"><?php echo $paginator->sort('Ngày','ngay');?></th>
	<th rowspan="2"><?php echo $paginator->sort('Nội dung công việc','congviec');?></th>
    <th colspan="3">Khối lượng</th>
    <th colspan="3">Thành phần</th>
    <th colspan="3">Yêu cầu</th>
    <th rowspan="2"><?php echo $paginator->sort('Ghi chú','ghichu');?></th>

	
	<th class="actions" rowspan="2"><?php __('Hành động');?></th>
</tr>
<tr>
    <th><?php echo $paginator->sort('Đơn vị tính','dvt_id');?></th>
	<th><?php echo $paginator->sort('Mục tiêu','muctieu');?></th>
	<th><?php echo $paginator->sort('Chỉ tiêu giao','chitieu');?></th>
	<th><?php echo $paginator->sort('Chủ trì','chutri');?></th>
	<th><?php echo $paginator->sort('Người thực hiện','thuchien');?></th>
	<th><?php echo $paginator->sort('Phối hợp','phoihop');?></th>
    <th><?php echo $paginator->sort('Diễn giải','dgiai');?></th>
	<th><?php echo $paginator->sort('Thời gian thực hiện','tgian');?></th>
	<th><?php echo $paginator->sort('Địa điểm','diadiem');?></th>
	
	
</tr>
<?php
$i = 0;
foreach ($khtuans as $khtuan):
	$class = null;
	if ($i++ % 2 == 0) {
		$class = ' class="altrow"';
	}
?>
	<tr<?php echo $class;?>>
	     <td>
			<?php 
              if(date('w',strtotime($khtuan['Khtuan']['ngay']))==0)
                echo 'Chủ nhật';
             else
                echo 'Thứ '.(date('w',strtotime($khtuan['Khtuan']['ngay']))+1);
             echo '<br>';
            echo date('d/m/Y',strtotime($khtuan['Khtuan']['ngay'])); ?>
		</td>
		<td>
			<?php echo $khtuan['Khtuan']['congviec']; ?>
		</td>
		<td>
			<?php echo $khtuan['Dvt']['donvitinh']; ?>
               
		</td>
		<td>
			<?php echo $khtuan['Khtuan']['muctieu']; ?>
		</td>
		<td>
			<?php echo $khtuan['Khtuan']['chitieu']; ?>
		</td>
		<td>
			<?php echo $khtuan['Khtuan']['chutri']; ?>
		</td>
		<td>
			<?php echo $khtuan['Khtuan']['thuchien']; ?>
		</td>
		<td>
			<?php echo $khtuan['Khtuan']['phoihop']; ?>
		</td>
		<td>
			<?php echo $khtuan['Khtuan']['dgiai']; ?>
		</td>
		<td>
			<?php echo date('H\hi',strtotime($khtuan['Khtuan']['tgian'])).'-'.date('H\hi',strtotime($khtuan['Khtuan']['tgkt'])); ?>
		</td>
		<td>
			<?php echo $khtuan['Khtuan']['diadiem']; ?>
		</td>
		<td>
			<?php echo $khtuan['Khtuan']['ghichu']; ?>
		</td>
		
		<td class="actions">
			
			<?php echo $html->link(__('Sửa', true), array('action' => 'edit', $khtuan['Khtuan']['id'],$kehoach)); ?>
			<?php echo $html->link(__('Xóa', true), array('action' => 'delete', $khtuan['Khtuan']['id'],$khtuan['Khtuan']['kehoach_id']), null, sprintf(__('Are you sure you want to delete # %s?', true), $khtuan['Khtuan']['id'])); ?>
		</td>
	</tr>
 <?php endforeach; ?>
    <tr>
    
    <?php 
	echo $form->create('Khtuan',array('url'=>'add/'.$kehoach.'/'.$id_dv));
?>
	<td><?php
	 echo $form->input('ngay',array('label'=>false,'type'=>'text','class'=>'datepick'));
?></td>
    <td>	<?php
	echo $form->input('congviec',array('label'=>false,'type'=>'textarea'));
?></td>
    <td><?php
	echo $form->input('dvt_id',array('label'=>false));
?>
             <br />
  <?php echo $html->link('Thêm đơn vị tính (nếu chưa có)', array('controller'=>'dvts','action' => 'add'),array('target' => '_blank'));?>
 
</td>
    <td><?php
		echo $form->input('muctieu',array('label'=>false,'type'=>'textarea'));
?></td>
    <td><?php
		echo $form->input('chitieu',array('label'=>false,'type'=>'textarea'));
?></td>
    <td><?php
	echo $form->input('chutri',array('label'=>false,'type'=>'textarea'));
?></td>
    <td><?php
		echo $form->input('thuchien',array('label'=>false,'type'=>'textarea'));
?></td>
    <td>	<?php
	echo $form->input('phoihop',array('label'=>false,'type'=>'textarea'));
?></td>
    <td><?php
		echo $form->input('dgiai',array('label'=>false,'type'=>'textarea'));
?></td>
    <td>	<?php
	echo $form->input('tgian',array('label'=>false));
    echo $form->input('tgkt',array('label'=>false));
?></td>
    <td>	<?php
	echo $form->input('diadiem',array('label'=>false,'type'=>'textarea'));
?></td>
    <td>	<?php
	echo $form->input('ghichu',array('label'=>false,'type'=>'textarea'));
?></td>
	
<td><?php echo $form->end('Lưu');?></td>

    </tr>

</table>
</div>
</div>
<div class="paging">
	<?php echo $paginator->prev('<< '.__('previous', true), array(), null, array('class'=>'disabled'));?>
 | 	<?php echo $paginator->numbers();?>
	<?php echo $paginator->next(__('next', true).' >>', array(), null, array('class' => 'disabled'));?>
</div>
